package cn.limc.ohoscharts.demo.slice;

import cn.limc.ohoscharts.demo.common.BaseAbility;
import cn.limc.ohoscharts.demo.ResourceTable;
import cn.limc.ohoscharts.axis.Axis;
import cn.limc.ohoscharts.entity.IStickEntity;
import cn.limc.ohoscharts.entity.ListChartData;
import cn.limc.ohoscharts.view.StickChart;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.utils.Color;

public class StickChartAbility extends BaseAbility {

  StickChart stickchart;

  @Override
  protected void onStart(Intent intent) {
    super.onStart(intent);
    setUIContent(ResourceTable.Layout_ability_stick_chart);

    initStickChart();
  }


//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        // Inflate the menu; this adds items to the action bar if it is present.
//        getMenuInflater().inflate(R.menu.stick_chart, menu);
//        return true;
//    }

  private void initStickChart() {
    this.stickchart = (StickChart) findComponentById(ResourceTable.Id_stickchart);

    stickchart.setAxisXColor(Color.LTGRAY.getValue());
    stickchart.setAxisYColor(Color.LTGRAY.getValue());
    stickchart.setLatitudeColor(Color.GRAY.getValue());
    stickchart.setLongitudeColor(Color.GRAY.getValue());
    stickchart.setBorderColor(Color.LTGRAY.getValue());
    stickchart.setLongitudeFontColor(Color.WHITE.getValue());
    stickchart.setLatitudeFontColor(Color.WHITE.getValue());
    stickchart.setDataQuadrantPaddingTop(6);
    stickchart.setDataQuadrantPaddingBottom(1);
    stickchart.setDataQuadrantPaddingLeft(1);
    stickchart.setDataQuadrantPaddingRight(1);
    // stickchart.setAxisYTitleQuadrantWidth(50);
    // stickchart.setAxisXTitleQuadrantHeight(20);
    stickchart.setAxisXPosition(Axis.AXIS_X_POSITION_BOTTOM);
    stickchart.setAxisYPosition(Axis.AXIS_Y_POSITION_RIGHT);

    // 最大显示足数
    // stickchart.setMaxSticksNum(52);
    // 最大纬线数
    // stickchart.setLatitudeNum(2);
    // 最大经线数
    // stickchart.setLongitudeNum(3);
    // 最大价格
    stickchart.setMaxValue(10000);
    // 最小价格
    stickchart.setMinValue(100);

    stickchart.setDisplayLongitudeTitle(true);
    stickchart.setDisplayLatitudeTitle(true);
    stickchart.setDisplayLatitude(true);
    stickchart.setDisplayLongitude(true);
    ShapeElement background = new ShapeElement();
    background.setRgbColor(new RgbColor(00, 00, 00));
    stickchart.setBackground(background);


    stickchart.setDataMultiple(100);
    stickchart.setAxisYDecimalFormat("#,##0.00");
    stickchart.setAxisXDateTargetFormat("yyyy/MM/dd");
    stickchart.setAxisXDateSourceFormat("yyyyMMdd");

    // 为chart1增加均线
    stickchart.setStickData(new ListChartData<IStickEntity>(vol));
  }

}
